package com.yy.school;

import com.yy.school.pojo.*;
import com.yy.school.util.ScoreDBUtil;
import com.yy.school.vo.ScoreVO;
import com.yy.school.util.StudentDBUtil;
import com.yy.school.util.TeacherDBUtil;


import java.util.List;
import java.util.Scanner;

public class MainApp {
    public static void main(String[] args) {

        ScoreDBUtil scoreDBUtil = new ScoreDBUtil();
        TeacherDBUtil teacherDBUtil = new TeacherDBUtil();
        StudentDBUtil studentDBUtil = new StudentDBUtil();
        String property = System.getProperty("sun.boot.class.path");
        System.out.println("property = " + property);
        String property1 = System.getProperty("java.ext.dirs");
        System.out.println("property1 = " + property1);
        String property2 = System.getProperty("java.class.path");
        System.out.println("property2 = " + property2);
        Scanner sc = new Scanner(System.in);
        System.out.println("======欢迎进入学生管理系统======");
        System.out.println("1.学生系统");
        System.out.println("2.教师系统");
        System.out.println("3.工作人员系统");
        System.out.println("4.学校管理系统");
        System.out.println("请选择（1----4）");
        String choice = sc.next();
        switch (choice) {
            case "1":
                System.out.println("你进入了学生系统");
                System.out.println("1.1 查看成绩");
                System.out.println("1.2 提交请假审批");
                System.out.println("1.3 查看个人信息");
                System.out.println("1.4 故障报修");
                System.out.println("1.5 课程查询");
                System.out.println("1.6 选修课程");
                System.out.println("1.7 提交作业");
                System.out.println("1.8 查看学校/教师通知");
                choice = sc.next();
                if ("1.1".equals(choice)) {
                    System.out.println("请输入查询学生编号");
                    int sid = sc.nextInt();
                    List<ScoreVO> scoreBySid = scoreDBUtil.getScoreBySid(sid);

                    scoreBySid.stream().forEach(System.out::println);
                }
                //提交请假审批
                if ("1.2".equals(choice)) {
                    studentDBUtil.leave();
                }
                //查看个人信息
                if ("1.3".equals(choice)) {
                    System.out.println("请输入学生编号");
                    int sid = sc.nextInt();
                    Student stu = studentDBUtil.getStuBySid(sid);
                    System.out.println(stu);
                }
                //故障保修
                if ("1.4".equals(choice)) {
                    studentDBUtil.addFault();
                }
                //查询课程
                if ("1.5".equals(choice)) {
                    List<Course> list = studentDBUtil.getStuCourse();
                    System.out.println("该学生选择的课程为");
                    list.stream().forEach(System.out::println);
                }
                //选修课程
                if ("1.6".equals(choice)) {
                    studentDBUtil.addCourse();
                }
                //学生提交作业功能
                if ("1.7".equals(choice)) {
                    System.out.println("提交作业正在开发中");
                }
                //查看学校通知
                if ("1.8".equals(choice)) {
                    List<Notice> notice = studentDBUtil.getNotice();
                    notice.stream().forEach(System.out::println);
                }
                break;
            case "2":
                System.out.println("你进入了教师系统");
                System.out.println("2.1 查看个人信息");
                System.out.println("2.2 审核学生请假");
                System.out.println("2.3 发起调课");
                System.out.println("2.4 查看全班成绩学分");
                System.out.println("2.5 布置作业");
                System.out.println("2.6 批改作业");
                System.out.println("2.7 故障报修");
                System.out.println("2.8 查看学校通知");
                System.out.println("请输入选择（2.1--2.8）");
                choice = sc.next();
                //查看教师个人信息
                if("2.1".equals(choice)){
                    System.out.println("请输入教师编号tid'");
                    int tid = sc.nextInt();
                    Teacher teacher = teacherDBUtil.getTeacherByTid(tid);
                    System.out.println(teacher);
                }
                //审核学生请假
                if ("2.2".equals(choice)) {
                    List<Leave> leaves = teacherDBUtil.getLeaves();
                    leaves.stream().forEach(System.out::println);
                    System.out.println("是否开始审批假条(y/n)");
                    choice = sc.next();
                    if ("y".equals(choice)) {
                        leaves.stream().filter(s -> s.getStatus().equals("未审批")).forEach(System.out::println);
                        System.out.println("请输入请假的id值，多个id值之间用，分割");
                        sc.nextLine();
                        choice = sc.nextLine();
                        System.out.println("choice = " + choice);
                        teacherDBUtil.updateLeaves(choice);
                    }
                }
                //发起调课
                if("2.3".equals(choice)){
                    System.out.println("发起调课功能开发中");
                }
                //查看全班成绩学分
                if("2.4".equals(choice)){

                }
                break;
            case "3":
                System.out.println("你进入了工作人员系统");
                break;
            case "4":
                System.out.println("你进入了学校管理系统");
                break;
            default:
                System.out.println("输入有误，请重写输入");
                break;
        }
    }
}
